package twPkg;

import twitter4j.*;
import twitter4j.auth.AccessToken;
import twitter4j.auth.RequestToken;

import java.util.List;


/**
 * @author Yusuke Yamamoto - yusuke at mac.com
 * @since Twitter4J 2.1.7
 */
public class SearchTweets {
    /**
     * Usage: java twitter4j.examples.search.SearchTweets [query]
     *
     * @param args
     */
	public static List<Status> getTweets(String q){
	Twitter twitter = new TwitterFactory().getInstance();
	 twitter.setOAuthConsumer("nIOrFFse65VoV4aPEezerg", "q25ZOnU2P3E577dkAXqqxU3QEPepzCsk5oBSDtM2CA");
	 twitter.setOAuthAccessToken(new AccessToken("51434906-H44S2ew9M43sOYd3JNjJUmbLv08bW3WBcY9VzrdDZ","WaO0tEPLupOOS3PS81iARv8AfO8hxiGD0Zm8Mhkxjw"));
   
	
	List<Status> tweets = null;
    try {
    	
        Query query = new Query(q);
        
        QueryResult result;
       // do {
            result = twitter.search(query);
             tweets = result.getTweets();
            
        //} while ((query = result.nextQuery()) != null);
        //System.exit(0);
    } catch (TwitterException te) {
    	 te.printStackTrace();
         System.out.println("Failed to search tweets: " + te.getMessage());
         System.exit(-1);
    }
    
   
	return tweets;
	}
}
